﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Security;
using DrivingCRM.Controller;

namespace DrivingCRM.Views.Private.Forum
{
    public partial class AddDiscussion : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Insert_button_Click(object sender, EventArgs e)
        {
            MembershipUser u = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            Guid mon_id = ((Guid)u.ProviderUserKey);
            string ret = EntityManager.AddDiscussion(this.TB_Title.Text, this.RE_Description.Text, mon_id);
            if (ret == "No error")
            {
                this.L_ErrorMessage.Text = "La nouvelle discussion a correctement été ajouté";
                Response.Redirect("ListDiscussions.aspx");
            }
            else
                this.L_ErrorMessage.Text = "Une erreur est survenue lors de l'ajout d'une discussion, veuillez saisir les champs requis.";
        }
        
    }
}